<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
  <head>
    <title>A canvas resize example</title>

    <script type="text/xaml" id="xaml"><?xml version="1.0"?>
      <Canvas xmlns="http://schemas.microsoft.com/client/2007"></Canvas></script>
<script type="text/javascript" src="../uupaa-excanvas.js"></script>

    <script>
      function boot() {
        drawShape(document.getElementById('canvas'));
        drawShape(document.getElementById('vmlcanvas'));
      }
      function drawShape(canvas){
        var ctx = canvas.getContext('2d');

        // Draw shapes
        ctx.rotate(Math.PI / 36);
        ctx.save();
        ctx.fillRect(25,25,100,100);
        ctx.clearRect(45,45,60,60);
        ctx.strokeRect(50,50,50,50);

        ctx.font = "64pt Arial";
        ctx.textBaseline = "top";

        ctx.fillStyle = "orange";
        ctx.fillText("fill", 22, 22);
        ctx.restore();
      }
      function wide() {
        var e;
        e = document.getElementById('canvas');
        e.width = parseInt(e.width) + 10;
        e.height = parseInt(e.height) + 10;

        e = document.getElementById('vmlcanvas');
        e.width = parseInt(e.width) + 10;
        e.height = parseInt(e.height) + 10;
      }
      function reduce() {
        var e;
        e = document.getElementById('canvas');
        e.width = parseInt(e.width) - 10;
        e.height = parseInt(e.height) - 10;

        e = document.getElementById('vmlcanvas');
        e.width = parseInt(e.width) - 10;
        e.height = parseInt(e.height) - 10;
      }
      function redraw() {
        drawShape(document.getElementById('canvas'));
        drawShape(document.getElementById('vmlcanvas'));
      }
    </script>
    <style type="text/css">
      body { margin: 20px; font-family: arial,verdana,helvetica; background: #fff;}
      h1 { font-size: 140%; font-weight:normal; color: #036; border-bottom: 1px solid #ccc; }
      canvas { border: 2px solid #000; float: left; margin-right: 20px; margin-bottom: 20px; }
      pre { float:left; display:block; background: rgb(238,238,238); border: 1px dashed #666; padding: 15px 20px; margin: 0 0 10px 0; }
    </style>
  </head>

  <body onload="uuCanvas.ready(boot);">
    <h1>canvas <code>resize</code> example</h1>
    <div>
      <input type="button" value="[+] wide" onclick="wide()" />
      <input type="button" value="[-] reduce" onclick="reduce()" />
      <input type="button" value="[R] redraw" onclick="redraw()" />
      <br />
      <canvas id="canvas" width="150" height="150"><p style="border: 1px solid red">fallback text</p></canvas>
      <canvas id="vmlcanvas" class="vml" width="150" height="150">fallback image<br /><img src="images/rhino.jpg" alt="alt image" /></canvas>
      <br />
<pre>
&lt;input type="button" value="[+] wide" onclick="wide()" /&gt;
&lt;input type="button" value="[-] reduce" onclick="reduce()" /&gt;
&lt;input type="button" value="[R] redraw" onclick="redraw()" /&gt;

&lt;canvas id="canvas" width="150" height="150"&gt;&lt;p style="border: 1px solid red"&gt;fallback text&lt;/p&gt;&lt;/canvas&gt;
&lt;canvas id="vmlcanvas" class="vml" width="150" height="150"&gt;fallback image&lt;br /&gt;&lt;img src="images/rhino.jpg" alt="alt image" /&gt;&lt;/canvas&gt;

function boot() {
  drawShape(document.getElementById('canvas'));
  drawShape(document.getElementById('vmlcanvas'));
}
function boot() {
  drawShape(document.getElementById('canvas'));
  drawShape(document.getElementById('vmlcanvas'));
}
function drawShape(canvas){
  var ctx = canvas.getContext('2d');

  // Draw shapes
  ctx.rotate(Math.PI / 36);
  ctx.save();
  ctx.fillRect(25,25,100,100);
  ctx.clearRect(45,45,60,60);
  ctx.strokeRect(50,50,50,50);

  ctx.font = "64pt Arial";
  ctx.textBaseline = "top";

  ctx.fillStyle = "orange";
  ctx.fillText("fill", 22, 22);
  ctx.restore();
}
function wide() {
  var e;
  e = document.getElementById('canvas');
  e.width = parseInt(e.width) + 10;
  e.height = parseInt(e.height) + 10;

  e = document.getElementById('vmlcanvas');
  e.width = parseInt(e.width) + 10;
  e.height = parseInt(e.height) + 10;
}
function reduce() {
  var e;
  e = document.getElementById('canvas');
  e.width = parseInt(e.width) - 10;
  e.height = parseInt(e.height) - 10;

  e = document.getElementById('vmlcanvas');
  e.width = parseInt(e.width) - 10;
  e.height = parseInt(e.height) - 10;
}
function redraw() {
  drawShape(document.getElementById('canvas'));
  drawShape(document.getElementById('vmlcanvas'));
}
</pre>
    </div>
  </body>
</html>
